package org.oncase.smcase.controller;

import org.oncase.smcase.dao.HibernateDAO;
import org.oncase.smcase.dao.ObjectiveDAO;
import org.oncase.smcase.entity.Frequency;
import org.oncase.smcase.entity.Objective;

import com.google.inject.Inject;

public class ObjectiveControllerImpl extends BSCControllerImpl<Objective> implements ObjectiveController {

	private HibernateDAO<Frequency> frequencyDAO;
	
	@Inject
	public ObjectiveControllerImpl(ObjectiveDAO dao, HibernateDAO<Frequency> frequencyDAO) {
		super(dao);
		this.frequencyDAO = frequencyDAO;
	}
	
	protected ObjectiveDAO getDAO() {
		return (ObjectiveDAO) super.getDAO();
	}

	@Override
	public void insert(Objective object) {
		this.frequencyDAO.insert(object.getFrequency());
		super.insert(object);
	}

	@Override
	public void update(Objective object) {
		this.frequencyDAO.update(object.getFrequency());
		super.update(object);
	}

	@Override
	public void delete(Objective object) {
		this.frequencyDAO.delete(object.getFrequency());
		object.setFrequency(null);
		super.delete(object);
	}
	
}
